/*
 * @Description: 将语法树 AST doc 转换为 HTML 渲染
 */

import HtmlGenerate from "./html_generate";
import MTreeWalker from "../tree_walker";

class MarkdownRender {

  render (mnode) {
    const htmlGenerate = new HtmlGenerate();
    const walker = new MTreeWalker(mnode);
    let buffer = '';
    let current;
    while (current = walker.next()) {
      if (htmlGenerate[current.mnode.type]) {
        buffer = htmlGenerate[current.mnode.type](buffer, current.mnode, current.close) || '';
      }
    }
    return buffer;
  }
}
export default MarkdownRender;